namespace MuseumApp.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class TagsAndMuseumTags : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Tags",
                c => new
                    {
                        TagId = c.Int(nullable: false, identity: true),
                        Name = c.String(),
                        Museum_MuseumId = c.Int(),
                    })
                .PrimaryKey(t => t.TagId)
                .ForeignKey("dbo.Museums", t => t.Museum_MuseumId)
                .Index(t => t.Museum_MuseumId);
            
            CreateTable(
                "dbo.MuseumTags",
                c => new
                    {
                        MuseumTagsId = c.Int(nullable: false, identity: true),
                        MuseumId = c.Int(nullable: false),
                        TagId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.MuseumTagsId)
                .ForeignKey("dbo.Museums", t => t.MuseumId, cascadeDelete: true)
                .ForeignKey("dbo.Tags", t => t.TagId, cascadeDelete: true)
                .Index(t => t.MuseumId)
                .Index(t => t.TagId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.MuseumTags", "TagId", "dbo.Tags");
            DropForeignKey("dbo.MuseumTags", "MuseumId", "dbo.Museums");
            DropForeignKey("dbo.Tags", "Museum_MuseumId", "dbo.Museums");
            DropIndex("dbo.MuseumTags", new[] { "TagId" });
            DropIndex("dbo.MuseumTags", new[] { "MuseumId" });
            DropIndex("dbo.Tags", new[] { "Museum_MuseumId" });
            DropTable("dbo.MuseumTags");
            DropTable("dbo.Tags");
        }
    }
}
